import type { FormSchema } from '@/components/core/schema-form/';
import type { TableColumn } from '@/components/core/dynamic-table';
import helper from '@/utils/helper';

export interface TableListItem {
  id: string;
  fileName: string;
  suffix: string;
  size: number;
  fileMD5: string;
  knowledgeBaseId: string;
  sliceType: number; // 切片方式
  createTime: string;
  isEmbedding: boolean; // 是否已向量化
}

export type TableColumnItem = TableColumn<TableListItem>;

// 定义表格列配置
export const baseColumns: TableColumnItem[] = [
  {
    title: '文件名',
    dataIndex: 'fileName',
    width: 200,
    ellipsis: true,
  },
  {
    title: '文件类型',
    dataIndex: 'suffix',
    width: 100,
  },
  {
    title: '文件大小',
    dataIndex: 'size',
    width: 120,
    customRender: ({ record }) => `${record.size} KB`,
  },
  {
    title: '切片方式',
    dataIndex: 'sliceType',
    width: 120,
    customRender: ({ record }) => {
      const sliceTypes = {
        0: '固定长度',
        1: 'QA问答',
        2: '段落'
      };
      return sliceTypes[record.sliceType as keyof typeof sliceTypes] || '';
    },
  },
  {
    title: '向量化状态',
    dataIndex: 'isEmbedding',
    width: 120,
    customRender: ({ record }) => {
      return record.isEmbedding ? '已向量化' : '未向量化';
    },
  },
  {
    title: '创建时间',
    dataIndex: 'creatTime',
    width: 180,
  },
];

// 搜索表单配置
export const searchFormSchema: FormSchema[] = [
  {
    field: 'knowledgeBaseId',
    component: 'Select',
    label: '所属知识库',
    componentProps: {
      placeholder: '请选择所属知识库',
    },
    colProps: {
      lg: 12,
      md: 24,
    },
  },
  {
    field: 'fileName',
    component: 'Input',
    label: '文件名',
    componentProps: {
      placeholder: '请输入文件名',
    },
    colProps: {
      lg: 12,
      md: 24,
    },
  },
]; 